<?php
namespace app\admin\model\store;
use think\Model;

/**
 *  商户续费记录模型
 * Class Renew
 * @package app\admin\model\store
 */
class Renew extends Model
{

    protected $name='store_renew_log';
    protected $updateTime=false;
    /**
     * 添加记录
     * @param $data
     */
    public static function add($data){
        $static = new static;
        $static->save(array_merge($data,['create_time'=>time()]));
    }


    public function getList($search = '',$search_time=''){
        $where=[];
        if(!empty($search))
        {
            $where=['wxapp.wxapp_name'=>['like', "%$search%"]];
        }
        if (!empty($search_time)){
            $times=explode('至',$search_time);
            $this->where('log.create_time','between time',$times);
        }
        return $this->alias('log')
            ->join('wxapp','wxapp.wxapp_id=log.wxapp_id')
            ->where($where)
            ->order(['log.create_time' => 'desc'])
            ->paginate(15, false, [
                'query' => \request()->request()
            ]);
    }


}